package com.lcfc.attend.controller;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lcfc.attend.entity.vo.DailyAttendanceVo;
import com.lcfc.attend.entity.vo.EmpDetailVo;
import com.lcfc.attend.entity.vo.ProjectEmpVo;
import com.lcfc.attend.entity.vo.ResultData;
import com.lcfc.attend.service.ProjectEmpService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping("/projectEmp")
public class ProjectEmpController {

	@Autowired
	private ProjectEmpService projectEmpService;
	/**
	 * 安检人员列表
	 * @param usercode
	 * @return
	 */
	@ApiOperation(value = "安检人员列表", notes = "安检人员列表")
    @PostMapping("/queryEmpList")
    public ResultData<ProjectEmpVo> queryEmpList(@ApiParam(value = "公司codes") @RequestParam(required = false) String officeCodes,
    		@ApiParam(value = "时间范围，周、月、季度、半年、年，分别以0,1,2,3,4代替") @RequestParam(required = false) String dateFlag) {
		List<ProjectEmpVo> list = projectEmpService.queryEmpList(officeCodes,dateFlag);
		ResultData<ProjectEmpVo> result = new ResultData<ProjectEmpVo>();
		result.setCode(0);
		result.setCount(list.size());
		result.setMsg("操作成功");
		result.setData(list);
		return result;
	}
	/**
	 * 安检人员详情
	 * @param officeCodes
	 * @return
	 */
	@ApiOperation(value = "安检人员详情", notes = "安检人员详情")
    @PostMapping("/queryEmpDetail")
    public ResultData<EmpDetailVo> queryEmpDetail(@ApiParam(value = "员工id") @RequestParam(required = false) String empId) {
		EmpDetailVo empDetail = projectEmpService.queryEmpDetail(empId);
		List<EmpDetailVo> list = new ArrayList<EmpDetailVo>();
		list.add(empDetail);
		ResultData<EmpDetailVo> result = new ResultData<EmpDetailVo>();
		result.setCode(0);
		result.setCount(1);
		result.setMsg("操作成功");
		result.setData(list);
		return result;
	}
	/**
	 * 人员打卡记录
	 * @param empId
	 * @return
	 */
	@ApiOperation(value = "人员打卡记录", notes = "人员打卡记录")
    @PostMapping("/queryDailyList")
    public ResultData<DailyAttendanceVo> queryDailyList(@ApiParam(value = "员工id") @RequestParam(required = false) String empId,
    		@ApiParam(value = "时间范围，周、月、季度、半年、年，分别以0,1,2,3,4代替") @RequestParam(required = false) String dateFlag) {
		List<DailyAttendanceVo> list = projectEmpService.queryDailyList(empId, dateFlag);
		ResultData<DailyAttendanceVo> result = new ResultData<DailyAttendanceVo>();
		result.setCode(0);
		result.setCount(1);
		result.setMsg("操作成功");
		result.setData(list);
		return result;
	}
}
